package com.enjoyor.soa.traffic.core.efoms.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.enjoyor.soa.traffic.core.efoms.domain.FacilitySimpleInfo;
import com.enjoyor.soa.traffic.core.efoms.enums.EnumDicPublic;
import com.enjoyor.soa.traffic.core.efoms.mapper.IFacilitySimpleInfoMapper;
import com.enjoyor.soa.traffic.core.efoms.service.IFacilitySimpleInfoService;
import com.enjoyor.soa.traffic.util.helper.LoggerHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;

@Service
@Transactional
public class FacilitySimpleInfoService implements IFacilitySimpleInfoService {

    @Autowired
    private IFacilitySimpleInfoMapper deviceDetailInfoMapper;

    @Override
    public FacilitySimpleInfo selectFacilitySimpleInfoById(String facilityTypeCode, String facilityId){
    	try {
    		FacilitySimpleInfo facilitySimpleInfo = new FacilitySimpleInfo();
    		List<FacilitySimpleInfo> facilitySimpleInfoList = this.selectFacilitySimpleInfoList(facilityTypeCode, 
    				facilityId, null, null, null, null, null, null, null, null, null, null, null, null, null, 
    				null, null, null,null);
	    	if(null != facilitySimpleInfoList && facilitySimpleInfoList.size() > 0) {
	    		facilitySimpleInfo = facilitySimpleInfoList.get(0);
	    	}
	    	return facilitySimpleInfo;
    	} catch (Exception e) {
			// TODO: handle exception
			LoggerHelper.LOG.error(e);
			throw e;
		}
    }
    
    @Override
	public List<FacilitySimpleInfo> selectFacilitySimpleInfoList(String facilityTypeCode, String facilityId,
			String facilityName, String key, String devStatusCode, String regionId, String signsType, String signsCode,
			String roadId, String blockId, String crossId, String manageDept, String manufact, String repStatusCode,
			String buildBeginDate, String buildEndDate, String updateBeginTime, String updateEndTime,String deviceStatus){
    	try {
	    	Map<String,Object> paramT = new HashMap<String ,Object>();
	    	paramT.put("facilityTypeCode", facilityTypeCode);
	    	paramT.put("facilityId", facilityId);
	    	paramT.put("facilityName", facilityName);
	    	paramT.put("key", key);
	    	paramT.put("devStatusCode", devStatusCode);
	    	paramT.put("regionId", regionId);
	    	paramT.put("signsType", signsType);
	    	paramT.put("signsCode", signsCode);
	    	paramT.put("roadId", roadId);
	    	paramT.put("blockId", blockId);
	    	paramT.put("crossId", crossId);
	    	paramT.put("manageDept", manageDept);
	    	paramT.put("manufact", manufact);
	    	paramT.put("repStatusCode", repStatusCode);
	    	paramT.put("buildBeginDate", buildBeginDate);
	    	paramT.put("buildEndDate", buildEndDate);
	    	paramT.put("updateBeginTime", updateBeginTime);
	    	paramT.put("updateEndTime", updateEndTime);
	    	paramT.put("deviceStatus", deviceStatus);
	    	return deviceDetailInfoMapper.selectFacilitySimpleInfoList(paramT);
    	} catch (Exception e) {
			// TODO: handle exception
			LoggerHelper.LOG.error(e);
			throw e;
		}
    }
    
    @Override
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public Page selectFacilitySimpleInfoPage(String facilityTypeCode, String facilityId,
			String facilityName, String key, String devStatusCode, String regionId, String signsType, String signsCode,
			String roadId, String blockId, String crossId, String manageDept, String manufact, String repStatusCode,
			String buildBeginDate, String buildEndDate, String updateBeginTime, String updateEndTime,String deviceStatus, Page page){
    	try {
	    	Map<String,Object> mapBean = new HashMap<String ,Object>();
	    	mapBean.put("facilityTypeCode", facilityTypeCode);
	    	mapBean.put("facilityId", facilityId);
	    	mapBean.put("facilityName", facilityName);
	    	mapBean.put("key", key);
	    	mapBean.put("devStatusCode", devStatusCode);
	    	mapBean.put("regionId", regionId);
	    	mapBean.put("signsType", signsType);
	    	mapBean.put("signsCode", signsCode);
	    	mapBean.put("roadId", roadId);
	    	mapBean.put("blockId", blockId);
	    	mapBean.put("crossId", crossId);
	    	mapBean.put("manageDept", manageDept);
	    	mapBean.put("manufact", manufact);
	    	mapBean.put("repStatusCode", repStatusCode);
	    	mapBean.put("buildBeginDate", buildBeginDate);
	    	mapBean.put("buildEndDate", buildEndDate);
	    	mapBean.put("updateBeginTime", updateBeginTime);
	    	mapBean.put("updateEndTime", updateEndTime);
	    	mapBean.put("deviceStatus", deviceStatus);
	    	page.setMapBean(mapBean);
	    	return deviceDetailInfoMapper.selectPageInfo(page);
    	} catch (Exception e) {
			// TODO: handle exception
			LoggerHelper.LOG.error(e);
			throw e;
		}
    }
}
